@include HeaderView
@layout Layout
@model ReportsModel
@section Title { Sheepshead Scores }
@section Scripts {
	@if (model.InfiniteScroll()) {
		<script src="ScrollHistoryCtrl.js"></script>
	}
}
@section Header {
	@html Partial<HeaderView>(model.GetViewType());
}
@for (auto report : model.GetReports()) {
	@html model.GetNavigationHtml();
	<div class="well" style="clear: both;">
		<h1 style="float: left;">@write report.GetTitle();</h1>
		@if (report.CanDelete()) {
			<form
				role="form"
				action="/sheepshead.cgi"
				method="post"
				style="float: right; position: relative; top: 20px;">
				<input type="hidden" name="action" value="delete-game">
				<input type="hidden" name="gameId" value="@write report.GetGameId();">
				<button type="submit" class="btn">Delete</button>
			</form>
		}
		<table class="table table-striped">
			<thead>
				<tr>
					<th>Player</th>
					<th>Score</th>
				</tr>
			</thead>
			<tbody>
			@for (auto playerScore : report.GetPlayerScores()) {
				<tr>
					<td><a href="/sheepshead.cgi?action=report-player&player=@url playerScore.GetName();">@write playerScore.GetName();</a></td>
					<td>@write playerScore.GetScore();</td>
				</tr>
			}
			</tbody>
			<tfoot>
				<tr class="success">
					<td>P.S.</td>
					<td>@write report.GetPointSpread();</td>
				</tr>
			</tfoot>
		</table>
	</div>
}
@if (model.InfiniteScroll()) {
	<div ng-controller="ScrollHistoryCtrl" style="overflow: auto;" when-scrolled="loadMore()">
		<div class="well" ng-repeat="report in reports">
			<h1 style="float: left;">{{report.title}}</h1>
			<form
				role="form"
				action="/sheepshead.cgi"
				method="post"
				style="float: right; position: relative; top: 20px;">
				<input type="hidden" name="action" value="delete-game">
				<input type="hidden" name="gameId" value="{{report.gameId}}">
				<button type="submit" class="btn">Delete</button>
			</form>
			<table class="table table-striped">
				<thead>
					<tr>
						<th>Player</th>
						<th>Score</th>
					</tr>
				</thead>
				<tbody>
					<tr ng-repeat="playerScore in report.playerScores">
						<td><a href="/sheepshead.cgi?action=report-player&player={{encodeURIComponent(playerScore.name)}}">{{playerScore.name}}</a></td>
						<td>{{playerScore.score}}</td>
					</tr>
				</tbody>
				<tfoot>
					<tr class="success">
						<td>P.S.</td>
						<td>{{report.pointSpread}}</td>
					</tr>
				</tfoot>
			</table>
		</div>
	</div>
}

